package com.wandian.cqcsk.adapter.mine;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseItemDraggableAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mylib.libcore.AppContext;
import com.wandian.cqcsk.R;

import java.util.List;

import static com.mylib.libcore.config.AppSPKeyConfig.FIRST_PAGE_NAME;

//拖拽adapter
public class HomeBtnDragRecycleAdapter extends BaseItemDraggableAdapter<String, BaseViewHolder> {

    private String selectItemText = AppContext.getInstance().getAppPreferencesHelper().getKeyValue(FIRST_PAGE_NAME)+"";
    public HomeBtnDragRecycleAdapter(int layoutResId, List<String> data) {
        super(layoutResId, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, String item) {
        TextView tv_btn_text = helper.getView(R.id.tv_btn_text);
        tv_btn_text.setText(item+"");
        ImageView iv_default = helper.getView(R.id.iv_default);
        iv_default.setVisibility(View.GONE);
        tv_btn_text.setBackground(mContext.getResources().getDrawable(R.drawable.button_sys_circle_ball));
        if(selectItemText.equals(item)) {
            tv_btn_text.setBackground(mContext.getResources().getDrawable(R.drawable.button_red_circle_ball));
            iv_default.setVisibility(View.VISIBLE);
        }
    }
    public void setItemSelect(String select){
        this.selectItemText = select;
        notifyDataSetChanged();
    }
}
